<?php 
$this->headLink(array('href' => '/cms/styles/style.css', 'rel' => "stylesheet", 'type' => "text/css"));
$this->headLink(array('href' => '/cms/styles/data-table.css', 'rel' => "stylesheet", 'type' => "text/css"));

$this->headScript()
	->appendFile('/cms/scripts/dojo/dojo.js','',array('djConfig'=> 'parseOnLoad:true, isDebug:false'))
	->setAllowArbitraryAttributes(true);

$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/shadowbox/build/adapter/shadowbox-base.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/shadowbox/build/shadowbox.js');

$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/content.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/Popup.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/TableData.js');
$this->headScript(Zend_View_Helper_HeadScript::SCRIPT,<<<EOD

dojo.require("dojo.fx");
dojo.require("dijit.Dialog");

var boxes = new Array();


Shadowbox.loadSkin('classic', '/cms/scripts/shadowbox/src/skin');
Shadowbox.loadLanguage('ru', '/cms/scripts/shadowbox/build/lang');
Shadowbox.loadPlayer(['html', 'iframe', 'img', 'swf'], '/cms/scripts/shadowbox/build/player');

var shadowbox_callback = function () {};

reset_shadowbox_callback = function () {
	shadowbox_callback = function () {};
} 

window.onload = function () {
	Shadowbox.init(
    	{
			modal:		true,
			onClose: function() { shadowbox_callback() }
		}
	);
}	
	
	
function doCollapse(el) {
	if (typeof boxes[el] == 'undefined'){
		boxes[el] = 0;
	}
	if (boxes[el]==1) {
		var currentAnimation = dojo.fx.wipeOut({node: el,duration: 300});
		boxes[el] = 0;
	} else {
		var currentAnimation = dojo.fx.wipeIn({node: el,duration: 300});
		boxes[el] = 1;
	}
    currentAnimation.play();
}

function showUser(user_id) {
                Shadowbox.open({
			      player:     'iframe',
			      title:      'Профиль пользователя',
			      content:    '/cms/users/view/user_id/'+user_id,
			      height:     450,
			      width:      750
			  });
			}
EOD
);

$this->layout()->body_attr = 'class="modal"';


$this->headStyle(<<<EOD
.messageBox {
	border: 1px dashed #CCCCCC;
	margin-bottom: 12px;
}
.messageBoxHeader {
	background-color: #EBEBEB;
	height: 26px;
}
.messageBoxCollapse {
	padding: 5px;
	float: left;
}
.messageBoxControlls {
	padding: 5px;
	float: right;
}
.messageBoxTitle {
	padding: 5px;
	float: left;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
.messageBoxBody {
	padding-top: 10px;
	padding-right: 5px;
	padding-bottom: 10px;
	padding-left: 31px;
	border-top-width: 1px;
	border-top-style: dashed;
	border-top-color: #CCCCCC;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	line-height: 16px;
	text-align: justify;
}
.messageBoxBodyControls {
	margin-top: 20px;
}

.dijitDialog {
background:#EEEEEE none repeat scroll 0 0;
border:1px solid #D3D3D3;
padding:0;
}
.dijitDialogTitleBar {
	background-color: #CCCCCC;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	padding: 6px;
}
.dijitDialogPaneContent {
	padding: 6px;
}

.dijitDialog {
padding:1px;
position:absolute;
z-index:999;
}
.dijitContentPane {
display:block;
overflow:auto;
}
.dijitDialogCloseIcon {
background:transparent url(images/spriteRoundedIconsSmall.png) no-repeat scroll right top;
cursor:pointer;
float:right;
height:15px;
position:absolute;
right:6px;
top:4px;
vertical-align:middle;
width:15px;
}

EOD
);
?>
<form action="<?= $this->url(array('controller' => 'formsender','action' => 'index'))?>" method="post">
  <table class="form" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="lablel">&nbsp;</td>
      <td><h1 id="winTitle">Форма отправки сообщений</h1></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="lablel">E-Mail:</td>
      <td><input name="email" type="text" class="modalInput" id="email" value="<?= htmlspecialchars($this->post_data['email']) ?>" style="width:400px" />
<?php 
if (isset($this->errors)) {
	if (isset($this->errors['email'])) {
?>
		<ul class="errors">
		<?php for ($e=0;$e<count($this->errors['email']);$e++) { ?>
			<li><?= $this->errors['email'][$e]?></li>
		<?php } ?>
		</ul>
<?php 		
	}
}
?>
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" class="okButton" id="okButton" value="Сохранить" />
          <input type="button" class="okButton" value="Отмена" onclick="window.parent.setTimeout('Shadowbox.close()',10)" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>


<?php 
for ($m=0;$m<$this->msg_list->length();$m++) { 
	$msg = $this->msg_list->item($m);
?>
<div class="messageBox">
  <div class="messageBoxHeader">
    <div class="messageBoxControlls">
        <a href="/cms/formsender/index/act/delete/id/<?=$this->form_id?>/msg_id/<?=$msg->_content_id ?>"><img src="/cms/images/cross.png" width="16" height="16" /></a></div>

    <div class="messageBoxCollapse"><a href="javascript:;" onclick="doCollapse('msg_<?=$msg->_content_id ?>')">
    <img src="/cms/images/plus_circle.png" alt="" width="16" height="16" /></a></div>
    <div class="messageBoxTitle">
    	<?php if ($msg->read_f==1) { ?>
        	<?=$msg->datetime?>: <?= $msg->from ?>
        <?php } else { ?>
        	<strong><?=$msg->datetime?>: <?=$msg->from?></strong>
        <?php } ?>
    </div>
  </div>
  <div class="messageBoxBody" id="msg_<?=$msg->_content_id ?>" style="display:none"><?=nl2br($msg->message)?>

  <div class="messageBoxBodyControls">
        <a href="/cms/formsender/index/act/delete/id/<?=$this->form_id?>/msg_id/<?=$msg->_content_id ?>"><img src="/cms/images/cross.png" width="16" height="16" align="absmiddle" /></a> 
        <a href="/cms/formsender/index/act/delete/id/<?=$this->form_id?>/msg_id/<?=$msg->_content_id ?>">Удалить</a> &nbsp;&nbsp;
	<?php if( $msg->read_f == 0 ) { ?>
        <a href="/cms/formsender/index/act/opend/id/<?=$this->form_id?>/msg_id/<?=$msg->_content_id ?>"><img src="/cms/images/mail_open.png" width="16" height="16" align="absmiddle" /></a> 
        <a href="/cms/formsender/index/act/opend/id/<?=$this->form_id?>/msg_id/<?=$msg->_content_id ?>">Отметить как прочитанное</a>
	<?php } ?>
    </div>

    
  </div>
</div>
<?php } ?>   